# Maintainer: Jan Alexander Steffens (heftig) <heftig@archlinux.org>
# Contributor: Ionut Biru <ibiru@archlinux.org>

pkgbase=gtkmm-4.0
pkgname=(gtkmm-4.0 gtkmm-4.0-docs)
pkgver=4.10.0
pkgrel=1
pkgdesc="C++ bindings for GTK 4"
url="https://www.gtkmm.org/"
arch=(x86_64)
license=(LGPL)
depends=(
  gtk4
  pangomm-2.48
)
makedepends=(
  cairomm-1.16-docs
  git
  glibmm-2.68-docs
  meson
  mm-common
  pangomm-2.48-docs
)
checkdepends=(xorg-server-xvfb)
_commit=301f8b2674350f23708f71b98c9a3fc94c0c7f80  # tags/4.10.0^0
source=("git+https://gitlab.gnome.org/GNOME/gtkmm.git#commit=$_commit")
sha256sums=('SKIP')

pkgver() {
  cd gtkmm
  git describe --tags | sed 's/[^-]*-g/r&/;s/-/+/g'
}

prepare() {
  cd gtkmm
}

build() {
  arch-meson gtkmm build -D maintainer-mode=true
  meson compile -C build
}

check() {
  xvfb-run -s '-nolisten local' \
    meson test -C build --print-errorlogs
}

_pick() {
  local p="$1" f d; shift
  for f; do
    d="$srcdir/$p/${f#$pkgdir/}"
    mkdir -p "$(dirname "$d")"
    mv "$f" "$d"
    rmdir -p --ignore-fail-on-non-empty "$(dirname "$f")"
  done
}

package_gtkmm-4.0() {
  depends+=(
    libcairomm-1.16.so
    libglibmm-2.68.so
    libpangomm-2.48.so
    libsigc-3.0.so
  )
  provides=(libgtkmm-4.0.so)

  meson install -C build --destdir "$pkgdir"

  cd "$pkgdir"
  _pick docs usr/share/{devhelp,doc}
}

package_gtkmm-4.0-docs() {
  pkgdesc+=" (documentation)"
  depends=()
  options=(!strip)

  mv docs/* "$pkgdir"
}

# vim:set sw=2 sts=-1 et:
